package com.zzyl.controller.manager;

import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.dto.NursingPlanPageQueryDto;
import com.zzyl.mapper.NursingProjectPlanMapper;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划管理")
@Slf4j
public class NursingPlanController {

    @Autowired
    NursingPlanService nursingPlanService;

    //TODO @ApiOperation("根据名称和状态分页查询")
    @GetMapping("/search")
    public ResponseResult<PageBean<NursingPlanVo>> nursePlanQuery(NursingPlanPageQueryDto dto) {
        log.info("根据名称和状态分页查询：{}", dto);
        PageBean<NursingPlanVo> pageBean = nursingPlanService.query(dto);
        return ResponseResult.success(pageBean);
    }

    @ApiOperation("添加护理计划")
    @PostMapping
    public ResponseResult<Void> nursePlanadd(@RequestBody NursingPlanDto dto) {
        nursingPlanService.add(dto);
        return ResponseResult.success();
    }

    //TODO @ApiOperation("根据ID查询护理计划")
    @GetMapping("/{id}")
    public ResponseResult<NursingPlanVo> getById(@PathVariable Integer id) {
        NursingPlanVo planVo = nursingPlanService.getById(id);
        return ResponseResult.success(planVo);
    }

    //TODO @ApiOperation("修改护理计划")
    @PutMapping("/{id}")
    public ResponseResult<Void> update(@RequestBody NursingPlanDto dto) {
        nursingPlanService.update(dto);
        return ResponseResult.success();
    }

    //TODO @ApiOperation("删除护理计划")
    @DeleteMapping("/{id}")
    public ResponseResult<Void> delete(@PathVariable Integer id) {
        nursingPlanService.deleteid(id);
        return ResponseResult.success();
    }

    //TODO @ApiOperation("启用、禁用护理计划")
    @PutMapping("/{id}/status/{status}")
    public ResponseResult<Void> status(@PathVariable Long id,@PathVariable Integer status) {
        nursingPlanService.updatestatus(id,status);
        return ResponseResult.success();

    }

    //TODO @ApiOperation("查询所有护理计划")
    @GetMapping
    public ResponseResult<List<NursingPlanVo>> findAll() {
        List<NursingPlanVo> list = nursingPlanService.fingAll();
        return ResponseResult.success(list);
    }
}
